*******************************************************************************************************************************
*******************************************************************************************************************************
* Documentation for Reproduction of
* Meta-analysis
* TESS Race Discrimination Meta-Analysis
* Stata version 15
* Data source: meta-analysis.dta
*******************************************************************************************************************************
*******************************************************************************************************************************

* use "meta-analysis.dta", clear

metan coeff bottomci topci if sample=="whites", random nograph
metan coeff bottomci topci if sample=="blacks", random nograph

metan coeff bottomci topci if sample=="whites"    & nohisp==0, random nograph
metan coeff bottomci topci if sample=="blacks"    & nohisp==0, random nograph
metan coeff bottomci topci if sample=="hispanics" & nohisp==0, random nograph

*******************************************************************************************************************************
*** Sample sizes
*******************************************************************************************************************************

sum n if sample=="whites"
display r(sum)

sum n if sample=="blacks"
display r(sum)

sum n if sample=="hispanics"
display r(sum)

*******************************************************************************************************************************
*** Meta-bias analysis
*******************************************************************************************************************************

gen whiteS = 1 if sample=="whites" 
metabias coeff stderr if whiteS==1, begg
metabias coeff stderr if whiteS==1, egger
scatter stderr coeff  if whiteS==1, yscale(reverse)

gen blackS = 1 if sample=="blacks" 
metabias coeff stderr if blackS==1, begg
metabias coeff stderr if blackS==1, egger
scatter stderr coeff  if blackS==1, yscale(reverse)

*******************************************************************************************************************************
*** Alternate specifications
*******************************************************************************************************************************

* No Cottrell and Neuberg (2004)
metan coeff bottomci topci if sample=="whites" & study!="Cottrell and Neuberg 2004", random nograph
metan coeff bottomci topci if sample=="blacks" & study!="Cottrell and Neuberg 2004", random nograph

* Only political candidate target experiments
metan coeff bottomci topci if sample=="whites" & candidate==1, random nograph
metan coeff bottomci topci if sample=="blacks" & candidate==1, random nograph

* Only worker target experiments
metan coeff bottomci topci if sample=="whites" & worker==1, random nograph
metan coeff bottomci topci if sample=="blacks" & worker==1, random nograph

* Include in the worker target experiments Pager and Freese 2003 and Pager 2006
metan coeff bottomci topci if sample=="whites" & (worker==1 | study=="Pager and Freese 2003" | study=="Pager 2006"), random nograph
metan coeff bottomci topci if sample=="blacks" & (worker==1 | study=="Pager and Freese 2003" | study=="Pager 2006"), random nograph

* Only published experiments
metan coeff bottomci topci if sample=="whites" & pubw==1, random nograph
metan coeff bottomci topci if sample=="blacks" & pubb==1, random nograph

* Only unpublished experiments
metan coeff bottomci topci if sample=="whites" & pubw==0, random nograph
metan coeff bottomci topci if sample=="blacks" & pubb==0, random nograph

*******************************************************************************************************************************
*** Meta-regression
*******************************************************************************************************************************

metareg coeff phone image yearw if sample=="whites", wsse(stderr)
metareg coeff phone image yearw if sample=="whites" & study!="Cottrell and Neuberg 2004", wsse(stderr)

metareg coeff phone image yearb if sample=="blacks", wsse(stderr)
metareg coeff phone image yearb if sample=="blacks" & study!="Cottrell and Neuberg 2004", wsse(stderr)

metareg coeff phone image yearb if sample=="hispanics", wsse(stderr)
metareg coeff phone image yearb if sample=="hispanics" & study!="Cottrell and Neuberg 2004", wsse(stderr)
